/*
 *
 *    Copyright (c) 2022 Project CHIP Authors
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

// THIS FILE IS GENERATED BY ZAP
// This file is generated from clusters-Commands.ipp.zapt

#include <clusters/CameraAvStreamManagement/Commands.h>

#include <app/data-model/Decode.h>
#include <app/data-model/StructDecodeIterator.h>
#include <app/data-model/WrappedStructEncoder.h>

namespace chip {
namespace app {
namespace Clusters {
namespace CameraAvStreamManagement {
namespace Commands {
namespace AudioStreamAllocate {

CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const
{
    DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
    encoder.Encode(to_underlying(Fields::kStreamUsage), streamUsage);
    encoder.Encode(to_underlying(Fields::kAudioCodec), audioCodec);
    encoder.Encode(to_underlying(Fields::kChannelCount), channelCount);
    encoder.Encode(to_underlying(Fields::kSampleRate), sampleRate);
    encoder.Encode(to_underlying(Fields::kBitRate), bitRate);
    encoder.Encode(to_underlying(Fields::kBitDepth), bitDepth);
    return encoder.Finalize();
}

CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader)
{
    detail::StructDecodeIterator __iterator(reader);
    while (true)
    {
        uint8_t __context_tag = 0;
        CHIP_ERROR err        = __iterator.Next(__context_tag);
        VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR);
        ReturnErrorOnFailure(err);

        if (__context_tag == to_underlying(Fields::kStreamUsage))
        {
            err = DataModel::Decode(reader, streamUsage);
        }
        else if (__context_tag == to_underlying(Fields::kAudioCodec))
        {
            err = DataModel::Decode(reader, audioCodec);
        }
        else if (__context_tag == to_underlying(Fields::kChannelCount))
        {
            err = DataModel::Decode(reader, channelCount);
        }
        else if (__context_tag == to_underlying(Fields::kSampleRate))
        {
            err = DataModel::Decode(reader, sampleRate);
        }
        else if (__context_tag == to_underlying(Fields::kBitRate))
        {
            err = DataModel::Decode(reader, bitRate);
        }
        else if (__context_tag == to_underlying(Fields::kBitDepth))
        {
            err = DataModel::Decode(reader, bitDepth);
        }

        ReturnErrorOnFailure(err);
    }
}
} // namespace AudioStreamAllocate.
namespace AudioStreamAllocateResponse {

CHIP_ERROR Type::Encode(DataModel::FabricAwareTLVWriter & aWriter, TLV::Tag aTag) const
{
    DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
    encoder.Encode(to_underlying(Fields::kAudioStreamID), audioStreamID);
    return encoder.Finalize();
}

CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader)
{
    detail::StructDecodeIterator __iterator(reader);
    while (true)
    {
        uint8_t __context_tag = 0;
        CHIP_ERROR err        = __iterator.Next(__context_tag);
        VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR);
        ReturnErrorOnFailure(err);

        if (__context_tag == to_underlying(Fields::kAudioStreamID))
        {
            err = DataModel::Decode(reader, audioStreamID);
        }

        ReturnErrorOnFailure(err);
    }
}
} // namespace AudioStreamAllocateResponse.
namespace AudioStreamDeallocate {

CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const
{
    DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
    encoder.Encode(to_underlying(Fields::kAudioStreamID), audioStreamID);
    return encoder.Finalize();
}

CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader)
{
    detail::StructDecodeIterator __iterator(reader);
    while (true)
    {
        uint8_t __context_tag = 0;
        CHIP_ERROR err        = __iterator.Next(__context_tag);
        VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR);
        ReturnErrorOnFailure(err);

        if (__context_tag == to_underlying(Fields::kAudioStreamID))
        {
            err = DataModel::Decode(reader, audioStreamID);
        }

        ReturnErrorOnFailure(err);
    }
}
} // namespace AudioStreamDeallocate.
namespace VideoStreamAllocate {

CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const
{
    DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
    encoder.Encode(to_underlying(Fields::kStreamUsage), streamUsage);
    encoder.Encode(to_underlying(Fields::kVideoCodec), videoCodec);
    encoder.Encode(to_underlying(Fields::kMinFrameRate), minFrameRate);
    encoder.Encode(to_underlying(Fields::kMaxFrameRate), maxFrameRate);
    encoder.Encode(to_underlying(Fields::kMinResolution), minResolution);
    encoder.Encode(to_underlying(Fields::kMaxResolution), maxResolution);
    encoder.Encode(to_underlying(Fields::kMinBitRate), minBitRate);
    encoder.Encode(to_underlying(Fields::kMaxBitRate), maxBitRate);
    encoder.Encode(to_underlying(Fields::kKeyFrameInterval), keyFrameInterval);
    encoder.Encode(to_underlying(Fields::kWatermarkEnabled), watermarkEnabled);
    encoder.Encode(to_underlying(Fields::kOSDEnabled), OSDEnabled);
    return encoder.Finalize();
}

CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader)
{
    detail::StructDecodeIterator __iterator(reader);
    while (true)
    {
        uint8_t __context_tag = 0;
        CHIP_ERROR err        = __iterator.Next(__context_tag);
        VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR);
        ReturnErrorOnFailure(err);

        if (__context_tag == to_underlying(Fields::kStreamUsage))
        {
            err = DataModel::Decode(reader, streamUsage);
        }
        else if (__context_tag == to_underlying(Fields::kVideoCodec))
        {
            err = DataModel::Decode(reader, videoCodec);
        }
        else if (__context_tag == to_underlying(Fields::kMinFrameRate))
        {
            err = DataModel::Decode(reader, minFrameRate);
        }
        else if (__context_tag == to_underlying(Fields::kMaxFrameRate))
        {
            err = DataModel::Decode(reader, maxFrameRate);
        }
        else if (__context_tag == to_underlying(Fields::kMinResolution))
        {
            err = DataModel::Decode(reader, minResolution);
        }
        else if (__context_tag == to_underlying(Fields::kMaxResolution))
        {
            err = DataModel::Decode(reader, maxResolution);
        }
        else if (__context_tag == to_underlying(Fields::kMinBitRate))
        {
            err = DataModel::Decode(reader, minBitRate);
        }
        else if (__context_tag == to_underlying(Fields::kMaxBitRate))
        {
            err = DataModel::Decode(reader, maxBitRate);
        }
        else if (__context_tag == to_underlying(Fields::kKeyFrameInterval))
        {
            err = DataModel::Decode(reader, keyFrameInterval);
        }
        else if (__context_tag == to_underlying(Fields::kWatermarkEnabled))
        {
            err = DataModel::Decode(reader, watermarkEnabled);
        }
        else if (__context_tag == to_underlying(Fields::kOSDEnabled))
        {
            err = DataModel::Decode(reader, OSDEnabled);
        }

        ReturnErrorOnFailure(err);
    }
}
} // namespace VideoStreamAllocate.
namespace VideoStreamAllocateResponse {

CHIP_ERROR Type::Encode(DataModel::FabricAwareTLVWriter & aWriter, TLV::Tag aTag) const
{
    DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
    encoder.Encode(to_underlying(Fields::kVideoStreamID), videoStreamID);
    return encoder.Finalize();
}

CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader)
{
    detail::StructDecodeIterator __iterator(reader);
    while (true)
    {
        uint8_t __context_tag = 0;
        CHIP_ERROR err        = __iterator.Next(__context_tag);
        VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR);
        ReturnErrorOnFailure(err);

        if (__context_tag == to_underlying(Fields::kVideoStreamID))
        {
            err = DataModel::Decode(reader, videoStreamID);
        }

        ReturnErrorOnFailure(err);
    }
}
} // namespace VideoStreamAllocateResponse.
namespace VideoStreamModify {

CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const
{
    DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
    encoder.Encode(to_underlying(Fields::kVideoStreamID), videoStreamID);
    encoder.Encode(to_underlying(Fields::kWatermarkEnabled), watermarkEnabled);
    encoder.Encode(to_underlying(Fields::kOSDEnabled), OSDEnabled);
    return encoder.Finalize();
}

CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader)
{
    detail::StructDecodeIterator __iterator(reader);
    while (true)
    {
        uint8_t __context_tag = 0;
        CHIP_ERROR err        = __iterator.Next(__context_tag);
        VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR);
        ReturnErrorOnFailure(err);

        if (__context_tag == to_underlying(Fields::kVideoStreamID))
        {
            err = DataModel::Decode(reader, videoStreamID);
        }
        else if (__context_tag == to_underlying(Fields::kWatermarkEnabled))
        {
            err = DataModel::Decode(reader, watermarkEnabled);
        }
        else if (__context_tag == to_underlying(Fields::kOSDEnabled))
        {
            err = DataModel::Decode(reader, OSDEnabled);
        }

        ReturnErrorOnFailure(err);
    }
}
} // namespace VideoStreamModify.
namespace VideoStreamDeallocate {

CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const
{
    DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
    encoder.Encode(to_underlying(Fields::kVideoStreamID), videoStreamID);
    return encoder.Finalize();
}

CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader)
{
    detail::StructDecodeIterator __iterator(reader);
    while (true)
    {
        uint8_t __context_tag = 0;
        CHIP_ERROR err        = __iterator.Next(__context_tag);
        VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR);
        ReturnErrorOnFailure(err);

        if (__context_tag == to_underlying(Fields::kVideoStreamID))
        {
            err = DataModel::Decode(reader, videoStreamID);
        }

        ReturnErrorOnFailure(err);
    }
}
} // namespace VideoStreamDeallocate.
namespace SnapshotStreamAllocate {

CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const
{
    DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
    encoder.Encode(to_underlying(Fields::kImageCodec), imageCodec);
    encoder.Encode(to_underlying(Fields::kMaxFrameRate), maxFrameRate);
    encoder.Encode(to_underlying(Fields::kMinResolution), minResolution);
    encoder.Encode(to_underlying(Fields::kMaxResolution), maxResolution);
    encoder.Encode(to_underlying(Fields::kQuality), quality);
    encoder.Encode(to_underlying(Fields::kWatermarkEnabled), watermarkEnabled);
    encoder.Encode(to_underlying(Fields::kOSDEnabled), OSDEnabled);
    return encoder.Finalize();
}

CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader)
{
    detail::StructDecodeIterator __iterator(reader);
    while (true)
    {
        uint8_t __context_tag = 0;
        CHIP_ERROR err        = __iterator.Next(__context_tag);
        VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR);
        ReturnErrorOnFailure(err);

        if (__context_tag == to_underlying(Fields::kImageCodec))
        {
            err = DataModel::Decode(reader, imageCodec);
        }
        else if (__context_tag == to_underlying(Fields::kMaxFrameRate))
        {
            err = DataModel::Decode(reader, maxFrameRate);
        }
        else if (__context_tag == to_underlying(Fields::kMinResolution))
        {
            err = DataModel::Decode(reader, minResolution);
        }
        else if (__context_tag == to_underlying(Fields::kMaxResolution))
        {
            err = DataModel::Decode(reader, maxResolution);
        }
        else if (__context_tag == to_underlying(Fields::kQuality))
        {
            err = DataModel::Decode(reader, quality);
        }
        else if (__context_tag == to_underlying(Fields::kWatermarkEnabled))
        {
            err = DataModel::Decode(reader, watermarkEnabled);
        }
        else if (__context_tag == to_underlying(Fields::kOSDEnabled))
        {
            err = DataModel::Decode(reader, OSDEnabled);
        }

        ReturnErrorOnFailure(err);
    }
}
} // namespace SnapshotStreamAllocate.
namespace SnapshotStreamAllocateResponse {

CHIP_ERROR Type::Encode(DataModel::FabricAwareTLVWriter & aWriter, TLV::Tag aTag) const
{
    DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
    encoder.Encode(to_underlying(Fields::kSnapshotStreamID), snapshotStreamID);
    return encoder.Finalize();
}

CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader)
{
    detail::StructDecodeIterator __iterator(reader);
    while (true)
    {
        uint8_t __context_tag = 0;
        CHIP_ERROR err        = __iterator.Next(__context_tag);
        VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR);
        ReturnErrorOnFailure(err);

        if (__context_tag == to_underlying(Fields::kSnapshotStreamID))
        {
            err = DataModel::Decode(reader, snapshotStreamID);
        }

        ReturnErrorOnFailure(err);
    }
}
} // namespace SnapshotStreamAllocateResponse.
namespace SnapshotStreamModify {

CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const
{
    DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
    encoder.Encode(to_underlying(Fields::kSnapshotStreamID), snapshotStreamID);
    encoder.Encode(to_underlying(Fields::kWatermarkEnabled), watermarkEnabled);
    encoder.Encode(to_underlying(Fields::kOSDEnabled), OSDEnabled);
    return encoder.Finalize();
}

CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader)
{
    detail::StructDecodeIterator __iterator(reader);
    while (true)
    {
        uint8_t __context_tag = 0;
        CHIP_ERROR err        = __iterator.Next(__context_tag);
        VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR);
        ReturnErrorOnFailure(err);

        if (__context_tag == to_underlying(Fields::kSnapshotStreamID))
        {
            err = DataModel::Decode(reader, snapshotStreamID);
        }
        else if (__context_tag == to_underlying(Fields::kWatermarkEnabled))
        {
            err = DataModel::Decode(reader, watermarkEnabled);
        }
        else if (__context_tag == to_underlying(Fields::kOSDEnabled))
        {
            err = DataModel::Decode(reader, OSDEnabled);
        }

        ReturnErrorOnFailure(err);
    }
}
} // namespace SnapshotStreamModify.
namespace SnapshotStreamDeallocate {

CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const
{
    DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
    encoder.Encode(to_underlying(Fields::kSnapshotStreamID), snapshotStreamID);
    return encoder.Finalize();
}

CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader)
{
    detail::StructDecodeIterator __iterator(reader);
    while (true)
    {
        uint8_t __context_tag = 0;
        CHIP_ERROR err        = __iterator.Next(__context_tag);
        VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR);
        ReturnErrorOnFailure(err);

        if (__context_tag == to_underlying(Fields::kSnapshotStreamID))
        {
            err = DataModel::Decode(reader, snapshotStreamID);
        }

        ReturnErrorOnFailure(err);
    }
}
} // namespace SnapshotStreamDeallocate.
namespace SetStreamPriorities {

CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const
{
    DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
    encoder.Encode(to_underlying(Fields::kStreamPriorities), streamPriorities);
    return encoder.Finalize();
}

CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader)
{
    detail::StructDecodeIterator __iterator(reader);
    while (true)
    {
        uint8_t __context_tag = 0;
        CHIP_ERROR err        = __iterator.Next(__context_tag);
        VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR);
        ReturnErrorOnFailure(err);

        if (__context_tag == to_underlying(Fields::kStreamPriorities))
        {
            err = DataModel::Decode(reader, streamPriorities);
        }

        ReturnErrorOnFailure(err);
    }
}
} // namespace SetStreamPriorities.
namespace CaptureSnapshot {

CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const
{
    DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
    encoder.Encode(to_underlying(Fields::kSnapshotStreamID), snapshotStreamID);
    encoder.Encode(to_underlying(Fields::kRequestedResolution), requestedResolution);
    return encoder.Finalize();
}

CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader)
{
    detail::StructDecodeIterator __iterator(reader);
    while (true)
    {
        uint8_t __context_tag = 0;
        CHIP_ERROR err        = __iterator.Next(__context_tag);
        VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR);
        ReturnErrorOnFailure(err);

        if (__context_tag == to_underlying(Fields::kSnapshotStreamID))
        {
            err = DataModel::Decode(reader, snapshotStreamID);
        }
        else if (__context_tag == to_underlying(Fields::kRequestedResolution))
        {
            err = DataModel::Decode(reader, requestedResolution);
        }

        ReturnErrorOnFailure(err);
    }
}
} // namespace CaptureSnapshot.
namespace CaptureSnapshotResponse {

CHIP_ERROR Type::Encode(DataModel::FabricAwareTLVWriter & aWriter, TLV::Tag aTag) const
{
    DataModel::WrappedStructEncoder encoder{ aWriter, aTag };
    encoder.Encode(to_underlying(Fields::kData), data);
    encoder.Encode(to_underlying(Fields::kImageCodec), imageCodec);
    encoder.Encode(to_underlying(Fields::kResolution), resolution);
    return encoder.Finalize();
}

CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader)
{
    detail::StructDecodeIterator __iterator(reader);
    while (true)
    {
        uint8_t __context_tag = 0;
        CHIP_ERROR err        = __iterator.Next(__context_tag);
        VerifyOrReturnError(err != CHIP_ERROR_END_OF_TLV, CHIP_NO_ERROR);
        ReturnErrorOnFailure(err);

        if (__context_tag == to_underlying(Fields::kData))
        {
            err = DataModel::Decode(reader, data);
        }
        else if (__context_tag == to_underlying(Fields::kImageCodec))
        {
            err = DataModel::Decode(reader, imageCodec);
        }
        else if (__context_tag == to_underlying(Fields::kResolution))
        {
            err = DataModel::Decode(reader, resolution);
        }

        ReturnErrorOnFailure(err);
    }
}
} // namespace CaptureSnapshotResponse.
} // namespace Commands
} // namespace CameraAvStreamManagement
} // namespace Clusters
} // namespace app
} // namespace chip
